package com.access.boot.autoconfigure.apisdk.context;

import com.access.boot.apisdk.SdkContext;
import com.access.boot.apisdk.mock.RegionMock;
import com.access.boot.apisdk.mock.SecretMock;
import com.access.boot.apisdk.mock.TokenMock;
import lombok.extern.slf4j.Slf4j;

import java.util.UUID;

/**
 * @author Yangzhen
 * @date 2022/5/30 17:50
 * @since 1.0.0
 */
@Slf4j
public class SdkContextManager {

    private SdkContextManager() {
    }

    private static SdkContextManager INSTANCE;

    public static SdkContextManager getInstance() {
        if (null == INSTANCE) {
            synchronized (SdkContextManager.class) {
                if (null == INSTANCE) {
                    INSTANCE = new SdkContextManager();
                }
            }
        }
        return INSTANCE;
    }

    public SdkContext getSdkContext() {
        String clientId = UUID.randomUUID().toString();
        String host = RegionMock.getRegion();
        String token = TokenMock.getToken();
        String secret = SecretMock.getSecret(clientId);
        return SdkContext.newInstance(host, clientId, secret, token);
    }

}
